#pragma once
#include <QApplication>
#include <QWidget>
#include <QImage>
#include <QPainter>

class VideoDisplayWidget : public QWidget {

public:
    explicit VideoDisplayWidget(QWidget *parent = nullptr) : QWidget(parent) {}

    void setFrame(const QImage &frame) {
        m_currentFrame = frame;
        update();
    }

protected:
    void paintEvent(QPaintEvent *event) override {
        QPainter painter(this);
        if (!m_currentFrame.isNull()) {
            painter.drawImage(0, 0, m_currentFrame.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
        } else {
            painter.fillRect(rect(), Qt::black);
        }
    }

private:
    QImage m_currentFrame;
};
